﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class ChucNang_Admin_Admin_ThongKeDoanhThuSanPhamTheoThang : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnThongKe_Click(object sender, EventArgs e)
    {
        DataDSTableAdapters.DATHANGTableAdapter adapter = new DataDSTableAdapters.DATHANGTableAdapter();
        DataDSTableAdapters.TAIKHOANTableAdapter tkadapter = new DataDSTableAdapters.TAIKHOANTableAdapter();
        DataDS.TAIKHOANDataTable tktable = new DataDS.TAIKHOANDataTable();
        int id_taikhoan=int.Parse(dropdownlistKhachHang.SelectedValue.ToString());
        int nam=int.Parse(dropdownNam.SelectedValue.ToString());
        tktable=tkadapter.TAIKHOAN_LayTheoId(id_taikhoan);
        imgKhachHang.ImageUrl=tktable.Rows[0]["Avatar"].ToString();
        imgKhachHang.DataBind();
        if (dropdownlistKhachHang.SelectedValue != null && dropdownNam.SelectedValue != null)
        {
            Label1.Visible = true;
            lbCMND.Visible = true;
            Label2.Visible = true;
            dropdownlistQuy.Visible = true;
            btnXem.Visible = true;
            lbCMND.Text = tktable.Rows[0]["CMND"].ToString();
            GridView1.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(nam, 1, id_taikhoan);
            GridView1.DataBind();
            GridView2.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(nam, 2, id_taikhoan);
            GridView2.DataBind();
            GridView3.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(nam, 3, id_taikhoan);
            GridView3.DataBind();
            GridView4.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(nam, 4, id_taikhoan);
            GridView4.DataBind();

        }
        else
        {
            if (dropdownlistKhachHang.SelectedValue != null)
            {
                lbCMND.Text = tktable.Rows[0]["CMND"].ToString();
                Label1.Visible = true;
                lbCMND.Visible = true;
                Label2.Visible = true;
                dropdownlistQuy.Visible = true;
                btnXem.Visible = true;
                GridView1.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(DateTime.Now.Year, 1, id_taikhoan);
                GridView1.DataBind();
                GridView2.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(DateTime.Now.Year, 2, id_taikhoan);
                GridView2.DataBind();
                GridView3.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(DateTime.Now.Year, 3, id_taikhoan);
                GridView3.DataBind();
                GridView4.DataSource = adapter.DATHANG_ThongKeMuaHangKhachHangTungQuy(DateTime.Now.Year, 4, id_taikhoan);
                GridView4.DataBind();
            }
        }

    }
    protected void btnXem_Click(object sender, EventArgs e)
    {
        int nam=int.Parse(dropdownNam.SelectedValue.ToString());
        int quy = int.Parse(dropdownlistQuy.SelectedValue.ToString());
        int id_tk = int.Parse(dropdownlistKhachHang.SelectedValue.ToString());
        DataDSTableAdapters.DATHANG_CHITIETDATHANG_SANPHAMTableAdapter adapter = new DataDSTableAdapters.DATHANG_CHITIETDATHANG_SANPHAMTableAdapter();
        GridView5.DataSource = adapter.DATHANG_CHITIETDATHANG_SANPHAM_ThongKeMuaHangKhachHangTheoQuy(quy, nam, id_tk);
        GridView5.DataBind();
    }
}
